<?php
/**
 * @package    Joomla.Tutorials
 * @subpackage Components
 * @link http://docs.joomla.org/Developing_a_Model-View-Controller_Component_-_Part_1#Creating_the_Entry_Point
 * @license    GNU/GPL
 */

// No direct access
defined( '_JEXEC' ) or die( 'Restricted access' );

jimport('joomla.application.component.controller');

/**
 * Hello World Component Controller
 *
 * @package    Joomla.Tutorials
 * @subpackage Components
 */
class NewMediaController extends JController
{
	/**
	 * Method to display the view
	 *
	 * @access    public
	 */
	function display()
	{
		parent::display();
	}

	function newMedia() {
	    JFactory::getDocument()->setMimeEncoding( 'application/json' );
	    JResponse::setHeader('Content-Disposition','attachment;filename="progress-report-results.json"');

	    $catid = JRequest::getVar('catid');
    	    $provinciaid = JRequest::getVar('provinciaid');
	    $title = JRequest::getVar('title');
	    
	    $model = & $this->getModel('Media');
	    $model->setCatid($catid);
	    $model->setProvinciaid($provinciaid);
	    $model->setTitle($title);
	    
	    $data = array(
	        'status' => $model->saveMedia()
	    );

	    echo json_encode( $data );
	    JFactory::getApplication()->close(); // or jexit();

	}

	function newProgramme() {
	    JFactory::getDocument()->setMimeEncoding( 'application/json' );
	    JResponse::setHeader('Content-Disposition','attachment;filename="progress-report-results.json"');

	    $catid = JRequest::getVar('catid');
    	    $provinciaid = JRequest::getVar('provinciaid');
	    $medid = JRequest::getVar('medid');
	    $title = JRequest::getVar('title');
	    
	    $model = & $this->getModel('Media');
	    $model->setCatid($catid);
	    $model->setProvinciaid($provinciaid);
    	    $model->setMedid($medid);
	    $model->setTitle($title);
	    
	    $data = array(
	        'status' => $model->saveProgramme()
	    );

	    echo json_encode( $data );
	    JFactory::getApplication()->close(); // or jexit();
	}
}
